<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	int i = 0;
%>
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>图书管理系统</title>
<script src="<%=basePath%>js/jquery.min.js"></script>
<style>
.card .table td, .card .table th {
	text-align: center;
}

.dropdown-item a:link {
	color: #000;
}

.dropdown-item a:visited {
	color: #000;
}
</style>
<!--favicon-->
<link rel="icon" href="images/favicon.ico" type="image/x-icon">
<!-- simplebar CSS-->
<link href="<%=basePath%>css/simplebar.css" rel="stylesheet" />
<!-- Bootstrap core CSS-->
<link href="<%=basePath%>css/bootstrap.min.css" rel="stylesheet" />
<!-- animate CSS-->
<link href="<%=basePath%>css/animate.css" rel="stylesheet"
	type="text/css" />
<!-- Icons CSS-->
<link href="<%=basePath%>css/icons.css" rel="stylesheet" type="text/css" />
<!-- Sidebar CSS-->
<link href="<%=basePath%>css/sidebar-menu.css" rel="stylesheet" />
<!-- Custom Style-->
<link href="<%=basePath%>css/app-style.css" rel="stylesheet" />
</head>

<body>
	<div id="wrapper" class="">
		<!--Start sidebar-wrapper-->
		<div id="sidebar-wrapper" data-simplebar="init"
			data-simplebar-auto-hide="true" class="active">
			<div class="simplebar-track vertical" style="visibility: visible;">
				<div class="simplebar-scrollbar"
					style="visibility: visible; top: 0px; height: 731px;"></div>
			</div>
			<div class="simplebar-track horizontal" style="visibility: hidden;">
				<div class="simplebar-scrollbar"></div>
			</div>
			<div class="simplebar-scroll-content"
				style="padding-right: 17px; margin-bottom: -34px;">
				<div class="simplebar-content"
					style="padding-bottom: 17px; margin-right: -17px;">
					<div class="brand-logo">
						<a href=<%=basePath%>> <img
							src="<%=basePath%>images/logo-icon.png" class="logo-icon"
							alt="logo icon">
							<h5 class="logo-text">图书管理系统</h5>
						</a>
					</div>
					<ul class="sidebar-menu do-nicescrol in">
						<li><a href="<%=basePath%>" class="waves-effect"> <i
								class="zmdi zmdi-view-dashboard"></i> <span> <c:if
										test="${empty logoner }">
										书籍查询
									</c:if> <c:if test="${logoner.getUserGrade() == 0}">
										书籍管理
									</c:if> <c:if test="${logoner.getUserGrade() == 1}">
										书籍查询
									</c:if>
							</span> <i class="fa fa-angle-left pull-right"></i>
						</a></li>
						<c:if test="${logoner.getUserGrade() == 0}">
							<li><a href="<%=basePath%>pages/addbook.jsp"
								class="waves-effect"> <i class="zmdi zmdi-view-dashboard"></i>
									<span>添加书籍</span> <i class="fa fa-angle-left pull-right"></i>
							</a></li>
							<li><a href="<%=basePath%>UserServlet?action=getalluser"
								class="waves-effect"> <i class="zmdi zmdi-view-dashboard"></i>
									<span>用户列表</span> <i class="fa fa-angle-left pull-right"></i>
							</a></li>
						</c:if>
						<c:if test="${not empty logoner }">
							<li><a href="<%=basePath%>BorrowServlet?action=getBorList"
								class="waves-effect"> <i class="zmdi zmdi-view-dashboard"></i>
									<span>借书详情</span> <i class="fa fa-angle-left pull-right"></i>
							</a></li>
						</c:if>
					</ul>
				</div>
			</div>
		</div>
		<!--End sidebar-wrapper-->

		<!--Start topbar header-->
		<header class="topbar-nav">
			<nav class="navbar navbar-expand fixed-top bg-white">
				<ul class="navbar-nav mr-auto align-items-center">
					<li class="nav-item"><a class="nav-link toggle-menu"
						href="javascript:void();"> <i class="icon-menu menu-icon"></i>
					</a></li>
				</ul>

				<ul class="navbar-nav align-items-center right-nav-link">
					<li class="nav-item"><c:if test="${empty logoner}">
							<a href="<%=basePath%>pages/logon.jsp"
								class="nav-link dropdown-toggle dropdown-toggle-nocaret">
								<p class="page-title">登录</p>
							</a>
						</c:if> <c:if test="${ not empty logoner}">
							<a class="nav-link dropdown-toggle dropdown-toggle-nocaret"
								data-toggle="dropdown" href="#">
								<h4 class="page-title">
									<c:if test="${empty logoner.getUserName()}">
										欢迎你，${logoner.getUserId() }
									</c:if>
									<c:if test="${not empty logoner.getUserName()}">
										欢迎你，${logoner.getUserName() }
									</c:if>
								</h4>
							</a>
							<ul class="dropdown-menu dropdown-menu-right">
								<li class="dropdown-item user-details"><a
									href="javaScript:void();">
										<div class="media">
											<div class="media-body">
												<h5 class="mt-2 user-title">ID:${logoner.getUserId()}</h5>
												<p class="user-subtitle">
													<c:if test="${empty logoner.getUserName()}">
													您没有设置您的姓名
												</c:if>
													<c:if test="${ not empty logoner.getUserName()}">
													姓名：${logoner.getUserName() }
												</c:if>
												</p>
											</div>
										</div>
								</a></li>
								<li class="dropdown-divider"></li>
								<li class="dropdown-item user-details"><a
									href="<%=basePath%>pages/updateInfo.jsp">
										<div class="media">
											<div class="media-body">
												<i class="icon-settings mr-2"></i> 修改或查看个人信息
											</div>
										</div>
								</a></li>
								<li class="dropdown-divider"></li>
								<li class="dropdown-item user-details"><a
									href="<%=basePath%>UserServlet?action=logout">
										<div class="media">
											<div class="media-body">
												<i class="icon-power mr-2"></i> 退出
											</div>
										</div>
								</a></li>
							</ul>
						</c:if>
				</ul>
			</nav>
		</header>
		<!--End topbar header-->
		<div class="clearfix"></div>

		<div class="content-wrapper">
			<div class="container-fluid">
				<!-- Breadcrumb-->
				<div class="row pt-2 pb-2">
					<div class="col-sm-9">
						<h4 class="page-title">用户列表</h4>
					</div>
				</div>
				<!-- End Breadcrumb-->
				<div class="row">
					<c:forEach items="${userlist}" var="aai" varStatus="aaiStatus">
						<div class="col-lg-3">
							<div class="card">
								<div class="card-body">
									<div class="card-title text-primary">ID：${aai.getUserId()}</div>
									<hr>
									<form name="<%=i%>"
										action="<%=basePath%>UserServlet?action=updateInfo"
										method="post">
										<input type="hidden" name="UserID" value="${aai.getUserId()}">
										<div class="form-group">
											<label for="UserName__<%=i%>">姓名</label> <input type="text"
												class="form-control" name="UserName" id="UserName__<%=i%>"
												placeholder="输入姓名" value="${aai.getUserName()}"
												style="background-image: url(&quot;&quot;); background-repeat: no-repeat; background-attachment: scroll; background-size: 16px 18px; background-position: 98% 50%; cursor: auto;">
										</div>
										<div class="form-group">
											<label for="UserPwd__<%=i%>">密码</label> <input type="text"
												class="form-control" name="UserPwd" id="UserPwd__<%=i%>"
												value="${aai.getUserPwd()}" placeholder="请输入新密码">
										</div>
										<div class="form-group">
											<label for="UserPhone__<%=i%>">电话</label> <input type="text"
												class="form-control" name="UserPhone" id="UserPhone__<%=i%>"
												value="${aai.getUserPhone()}"
												placeholder="Enter Your Mobile Number">
										</div>
										<div class="form-group">
											<label for="UserAddress__<%=i%>">住址</label> <input
												type="text" class="form-control" name="UserAddress"
												id="UserAddress__<%=i%>" value="${aai.getUserAddress()}"
												placeholder="Enter Password">
										</div>
										<div class="form-group">
											<div class="icheck-material-primary icheck-inline">
												<input type="radio" id="user__<%=i%>" name="userGrade"
													value="1" checked=""> <label for="user__<%=i%>">普通用户</label>
											</div>
											<div class="icheck-material-info icheck-inline">
												<input type="radio" id="admin__<%=i%>" name="userGrade"
													value="0"> <label for="admin__<%=i%>">管理员</label>
											</div>
											<script type="text/javascript">
												var userGrade = ${aai.getUserGrade()};
												if( userGrade == 0){
													$("#admin__<%=i++%>").click();
												}
											</script>
										</div>
										<div class="form-group">
											<button type="submit"
												formaction="<%=basePath%>UserServlet?action=deleteUser&UserID=${aai.getUserId()}"
												class="btn btn-danger shadow-danger waves-effect waves-light m-1">删除用户</button>
											<button type="submit"
												class="btn btn-primary shadow-primary waves-effect waves-light m-1"
												style="float: right;">更新信息</button>
										</div>
									</form>
								</div>
							</div>
						</div>
					</c:forEach>
				</div>
				<!--End Row-->

			</div>
			<!-- End container-fluid-->

		</div>
		<!--End content-wrapper-->
		<!--Start Back To Top Button-->
		<a href="javaScript:void();" class="back-to-top"
			style="display: inline;"><i class="fa fa-angle-double-up"></i> </a>
		<!--End Back To Top Button-->
	</div>
	<!-- Bootstrap core JavaScript-->
	<script src="<%=basePath%>js/jquery.min.js"></script>
	<script src="<%=basePath%>js/popper.min.js"></script>
	<script src="<%=basePath%>js/bootstrap.min.js"></script>
	<!-- simplebar js -->
	<script src="<%=basePath%>js/simplebar.js"></script>
	<!-- waves effect js -->
	<script src="<%=basePath%>js/waves.js"></script>
	<!-- sidebar-menu js -->
	<script src="<%=basePath%>js/sidebar-menu.js"></script>
	<!-- Custom scripts -->
	<script src="<%=basePath%>js/app-script.js"></script>
</body>

</html>